<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/18 0018
 * Time: 下午 1:49
 */
use yii\helpers\Url;
use common\models\Plug\Plug;
?>
<?php $this->beginBlock("content");?>
<div class="row">
    <div class="col-md-12 white-box">
        <form action="<?=Url::to(["set"])?>" method="post" rel-action="form" >

            <div class="row ">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">
                            插件名称
                        </label>
                        <input type="text" name="name" value="<?=@$ret["name"]?>" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="name"></div>
                    </div>
                </div>
            </div>
            <div class="row ">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">
                            MD5
                        </label>
                        <input type="text" name="md5" value="<?=@$ret["md5"]?>" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="md5"></div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">
                            下载地址
                        </label>
                        <input type="text" name="url" value="<?=@$ret["url"]?>" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="url"></div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label class="control-label">
                            延迟启动【分钟】
                        </label>
                        <input type="text" name="start_delayed" value="" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="start_delayed">开机多少分钟后运行
                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label class="control-label">
                            有效时长【分钟】
                        </label>
                        <input type="text" name="valid_time" value="" class="form-control" placeholder="">
                        <div class="form-control-feedback" rel-mark="valid_time">运行多少分钟后视为有效
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">自动关闭</label>
                        <div class="radio-list">
                            <?php foreach (Plug::getAutoCloseMap() as $key => $item): ?>
                                <label class="radio-inline p-0">
                                    <div class="radio radio-success">
                                        <input type="radio" name="auto_close" id="auto_close<?=$key?>" value="<?=$key?>" <?php if (@$ret['auto_close'] == $key) : ?>checked<?php endif ?>>
                                        <label for="auto_close<?=$key?>"><?=$item?></label>
                                    </div>
                                </label>
                            <?php endforeach ?>
                            <div class="form-control-feedback" rel-mark="auto_close">满足有效时长后不再启动
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">状态</label>
                        <div class="radio-list">
                            <?php foreach (Plug::getStatusMap() as $key => $item): ?>
                                <label class="radio-inline p-0">
                                    <div class="radio radio-success">
                                        <input type="radio" name="status" id="status<?=$key?>" value="<?=$key?>" <?php if (@$ret['status'] == $key) : ?>checked<?php endif ?>>
                                        <label for="status<?=$key?>"><?=$item?></label>
                                    </div>
                                </label>
                            <?php endforeach ?>
                            <div class="form-control-feedback" rel-mark="status">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="col-md-12 form-control-label ">互斥关系<!--span class="help"> e.g. "George deo"</span--></label>
                        <select class="selectpicker" data-style="btn-info btn-outline " data-live-search="true" data-title="无" tabindex="-98" name="mutex_id">
                            <?php foreach ($plugs as $item): ?>
                                <option value="<?=$item['id']?>" <?php if (@$ret["mutex_id"] == $item['id']) : ?>selected<?php endif ?>><?="【".$item["id"]."】" .  $item["name"]?></option>
                            <?php endforeach ?>
                        </select>
                        <div class="form-control-feedback" rel-mark="mutex_id"></div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="control-label">禁投区域</label>
                        <textarea class="form-control" rows="5" name="area" placeholder="逗号分隔城市"><?=@$ret["area"]?></textarea>
                        <div class="form-control-feedback" rel-mark="content"></div>
                    </div>
                </div>
            </div>
            <?php if (isset($ret["id"])):?>
                <input type="hidden" name="id" value="<?=$ret["id"]?>">
            <?php endif?>
            <button type="submit" class="btn btn-success waves-effect waves-light m-r-10 float-left">
                确认保存
            </button>
            <button type="button" class="btn btn-default waves-effect waves-light m-r-10" onclick="location.href='<?=Url::to(["index"])?>'">
                返回列表
            </button>
        </form>
    </div>

</div>
<?php $this->endBlock();?>
